package com.xy.ddd.core.mapper;

import com.xy.ddd.core.mapper.provider.BatchUpdateProvider;
import com.xy.ddd.core.po.BasePo;
import org.apache.ibatis.annotations.UpdateProvider;
import tk.mybatis.mapper.annotation.RegisterMapper;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.special.InsertListMapper;

import java.util.List;

/**
 * 通用Mapper接口,其他接口继承该接口即可
 *
 * @param <T>
 */
@RegisterMapper
public interface BaseMapper<T extends BasePo> extends Mapper<T>, InsertListMapper<T> {
    /**
     * 批量插入数据库，所有字段都插入，包括主键
     *
     * @return
     */
//    @Options(useGeneratedKeys = true, keyProperty = "id")
//    @InsertProvider(type = SpecialBatchProvider.class, method = "batchInsert")
//    int batchInsert(List<T> recordList);

    /**
     * 根据Example条件批量更新实体`record`包含的不是null的属性值
     *
     * @return
     */
    @UpdateProvider(type = BatchUpdateProvider.class, method = "dynamicSQL")
    int batchUpdateByPrimaryKeySelective(List<T> recordList);
}
